/** ⽤能API */

import { energyApi, statisticsApi, warnImgApi } from "@/utils/request";

/** 基于accountId（⽤户ID，由度能提供）获取token
 * @param { accountId } ⽤户ID
 */
export const getToken = (accountId: string) =>
  energyApi({
    url: "/v1/token",
    method: "post",
    data: {
      accountId:'085eb88c0928468983a839c99b436734' //accountId,
    },
  });
/** 获取碳排放
 * @param { id } 企业ID
 * @param { indicatorId } 核算分析ID
 * @param { duration } 统计期间day/month/year
 * @param { date } 具体⽇期
 * date=2025-03-09T00:00:00Z
enterpriseId=1
duration=DAY
assessmentPeriodType=1
energyType=(1电2蒸汽3水4天燃气5热9碳)
analysisDimensionId=3
indicatorId=5023903988659200
 */
export const getEnergy = (
  indicatorId: string,
  duration: "DAY" | "MONTH" | "YEAR",
  date: string,
  energyType: string | number,
  token: string
) =>
  energyApi({
    url: '/v1/openapi/dingXin',
    //`/v1/carbon/analysis/6034473486986240`,
    method: "get",
    params: {
      indicatorId,
      duration,
      date,
      enterpriseId: 1,
      assessmentPeriodType: 2,//1普通日期，2核算日
      energyType: energyType,//(1电2蒸汽3水4天燃气5热9碳)
      analysisDimensionId: 3
      //region: "gz",
      //language: "zh-cn",
    },
    headers: {'Authorization': token}
  });
// 获取预警数据
export const getstatistics = (period: 'day' | 'week' | 'month') => 
  statisticsApi({
    url: '/v1/statistics/alarm/types/top5',
    params: {
      period: period
    }
  })
// 获取异常图片
export const getWarnImg = (dir: string) => 
  warnImgApi({
    url: '/api/file/get',
    params: {
      dir: dir||'卷绕'
    }
  })
// 获取异常图片类型
export const getWarnImgType = () => 
  warnImgApi({
    url: '/api/file/getsubdir',
    method: "get"
})
